using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;

namespace TripleMatch
{
    public class DecorationCell : MonoBehaviour
    {
        [SerializeField] Button m_buttonClose;
        [SerializeField] Image m_imageDecoration;
        [SerializeField] Text m_textDecorationName;
        [SerializeField] Text m_textDecorationDiscription;

        private List<int> m_decorationIndexList;

        public void DisplayDecoration(List<int> decorationIndex)
        {
            m_decorationIndexList = decorationIndex.ToList();
            OnDisplayDecoration();
        }

        private void OnDisplayDecoration()
        {
            if (m_decorationIndexList.Count > 0)
            {
                Debug.Log("DisplayDecoration:" + m_decorationIndexList[0]);
                m_buttonClose.onClick.AddListener(OnClickClose);
                m_decorationIndexList.RemoveAt(0);
            }
            else
            {
                gameObject.SetActive(false);
                m_buttonClose.onClick.RemoveAllListeners();
            }
        }

        private void OnClickClose()
        {
            gameObject.SetActive(false);
            m_buttonClose.onClick.RemoveAllListeners();
            OnDisplayDecoration();
        }
    }

}
